#include <iostream>
#include <climits>
using namespace std;
int main()
{
    int pencil;
    int num_in[3], price_for_one[3];

    int price;
    int lowest_price = INT_MAX;
    cin >> pencil;
    for (int count = 0; count < 3; count++)
    {
        cin >> num_in[count] >> price_for_one[count];
    }
    for (int count = 0; count < 3; count++)
    {
        int packages = (pencil + num_in[count] - 1) / num_in[count];
        int price = packages * price_for_one[count];
        if (price < lowest_price)
        {
            lowest_price = price;
        }
    }

    cout << lowest_price << endl;
    return 0;
}